package com.luhongzhe;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.luhongzhe.gameview.CommonScene;
import com.luhongzhe.gameview.CommonGameView;
import com.luhongzhe.gameview.GameViewList;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.AdapterView.OnItemClickListener;

public class WayFd extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.main);
//        setContentView(new FallingBoxView(this));
        
        ListView listView = new ListView(this);
        setContentView(listView);
        
        SimpleAdapter adapter = new SimpleAdapter(this, GameViewList.getData(), 
        		android.R.layout.simple_list_item_1, 
        		new String[]{"title"}, new int[]{android.R.id.text1});
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(onListItemClickListener);
        
    }
    
    private OnItemClickListener onListItemClickListener = new OnItemClickListener()
    {
    	public void onItemClick(AdapterView<?> parent, View view, int position, long id)
    	{
    		HashMap<String, Object> map = (HashMap<String, Object>)parent.getItemAtPosition(position);
    		int gameId = (Integer)map.get("id");
    		
    		Intent intent = new Intent(WayFd.this, CommonScene.class);
    		Bundle bundle = new Bundle();
    		bundle.putInt("gameId", gameId);
    		intent.putExtras(bundle);
    		startActivity(intent);
    	}
	};

}